﻿#region License
/*Copyright (c) 2010 Andrew Collard (andrewcollard@hotmail.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.*/
#endregion

using System.IO;

namespace TorchView.Game
{
  /// <summary>
  /// Tips the player has read while using this character.
  /// Will not change if the Show Tips setting is turned off.
  /// </summary>
  public sealed class TipRead
  {
    const string TIPS_READ_FORMAT = "{0} (of 34)";

    public bool Inventory { get; set; }
    public bool Identification { get; set; }
    public bool InventoryFull { get; set; }
    public bool LowHealth { get; set; }
    public bool LowMana { get; set; }
    public bool Merchant { get; set; }
    public bool LevelUp { get; set; }
    public bool StatPoints { get; set; }
    public bool LearnSpell { get; set; }
    public bool Intro { get; set; }
    public bool Sockets { get; set; }
    public bool PetFleeing { get; set; }
    public bool Gambler { get; set; }
    public bool Enchanter { get; set; }
    public bool Transmuter { get; set; }
    public bool PetItems { get; set; }
    public bool PetItemsFull { get; set; }
    public bool Stash { get; set; }
    public bool Unknown18 { get; set; }
    public bool Spells { get; set; }
    public bool Quest { get; set; }
    public bool SharedStash { get; set; }
    public bool Unknown22 { get; set; }
    public bool Unknown23 { get; set; }
    public bool Unknown24 { get; set; }
    public bool Unknown25 { get; set; }
    public bool Unknown26 { get; set; }
    public bool Unknown27 { get; set; }
    public bool Unknown28 { get; set; }
    public bool Unknown29 { get; set; }
    public bool Unknown30 { get; set; }
    public bool Unknown31 { get; set; }
    public bool Unknown32 { get; set; }
    public bool Unknown33 { get; set; }
    private int Viewed { get; set; }

    public static TipRead Read(BinaryReader reader)
    {
      TipRead tipread = new TipRead();
      tipread.Viewed = 0;
      tipread.Inventory = tipread.CountViews(reader);
      tipread.Identification = tipread.CountViews(reader);
      tipread.InventoryFull = tipread.CountViews(reader);
      tipread.LowHealth = tipread.CountViews(reader);
      tipread.LowMana = tipread.CountViews(reader);
      tipread.Merchant = tipread.CountViews(reader);
      tipread.LevelUp = tipread.CountViews(reader);
      tipread.StatPoints = tipread.CountViews(reader);
      tipread.LearnSpell = tipread.CountViews(reader);
      tipread.Intro = tipread.CountViews(reader);
      tipread.Sockets = tipread.CountViews(reader);
      tipread.PetFleeing = tipread.CountViews(reader);
      tipread.Gambler = tipread.CountViews(reader);
      tipread.Enchanter = tipread.CountViews(reader);
      tipread.Transmuter = tipread.CountViews(reader);
      tipread.PetItems = tipread.CountViews(reader);
      tipread.PetItemsFull = tipread.CountViews(reader);
      tipread.Stash = tipread.CountViews(reader);
      tipread.Unknown18 = tipread.CountViews(reader);
      tipread.Spells = tipread.CountViews(reader);
      tipread.Quest = tipread.CountViews(reader);
      tipread.SharedStash = tipread.CountViews(reader);
      tipread.Unknown22 = tipread.CountViews(reader);
      tipread.Unknown23 = tipread.CountViews(reader);
      tipread.Unknown24 = tipread.CountViews(reader);
      tipread.Unknown25 = tipread.CountViews(reader);
      tipread.Unknown26 = tipread.CountViews(reader);
      tipread.Unknown27 = tipread.CountViews(reader);
      tipread.Unknown28 = tipread.CountViews(reader);
      tipread.Unknown29 = tipread.CountViews(reader);
      tipread.Unknown30 = tipread.CountViews(reader);
      tipread.Unknown31 = tipread.CountViews(reader);
      tipread.Unknown32 = tipread.CountViews(reader);
      tipread.Unknown33 = tipread.CountViews(reader);
      return tipread;
    }

    private bool CountViews(BinaryReader reader)
    {
      bool tipread = reader.ReadBoolean();
      if (tipread) Viewed++;
      return tipread;
    }

    public override string ToString()
    {
      return string.Format(TIPS_READ_FORMAT, Viewed);
    }
  }
}
